﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using Memorandum.DBContext;
using Memorandum.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Memorandum.ViewModel
{
    public enum VMType
    {
        Daily,
        Once
    }
   public class DailyRemindViewModel:ViewModelBase
   {
        private DateTime dateTime;

        public DateTime DisplayTime
        {
            get { return dateTime; }
            set { dateTime = value; }
        }
        private VMType type= VMType.Daily;

        public VMType ModelType
        {
            get { return type; }
            set { type= value; }
        }

        private string  title="主题";

        public string Title
        {
            get { return title; }
            set { title = value; }
        }

        private string content="这里是内容";

        public string Content
        {
            get { return content; }
            set { content = value; }
        }
        private ICommand submit;

        public ICommand Submit
        {
            get
            {
                if (submit == null)
                {
                    submit = new RelayCommand(() =>
                    {
                        if(VMType.Daily== ModelType)
                        {
                            SqliteDBContext.Instance.RemindItems.Add(new RemindItem() { Title = this.title, Content = this.content, AlarmTime = this.dateTime, dateTime=DateTime.Now,  type = RemindType.Daily });
                        }
                        else
                        {
                            SqliteDBContext.Instance.RemindItems.Add(new RemindItem() { Title = this.title, Content = this.content, AlarmTime = this.dateTime, dateTime = DateTime.Now, type = RemindType.Once });
                        }
                       
                        SqliteDBContext.Instance.SaveChanges();
                        Messenger.Default.Send("Message", Message.ShowSuccess);

                    });
                }
                return submit;
            }

        }
    }
}
